package de.bazinga.rotw.weapon.grenade;

import java.util.Stack;

import com.jme.math.Vector3f;
import com.jme.scene.Node;

import de.bazinga.rotw.network.message.NewBulletMessage;
import de.bazinga.rotw.person.Person;

public class SmokeGrenade extends Grenade {
	private static Stack<Smoke> unusedSmoke = new Stack<Smoke>();
	
	
	public void handleCollision(Person person, Node rootNode, Vector3f location) {
		// Smoke Granade Test
		Smoke smoke = getUnusedSmoke(location);
		rootNode.attachChild(smoke);
		smoke.getSmokeParticles().forceRespawn();
		
		smoke.hide();
	}

	public int getWeaponFlag() {
		return NewBulletMessage.SMOKEGRANADE;
	}
	
	
	
	public static synchronized void addUnusedSmoke(Smoke s) {
		unusedSmoke.push(s);
	}

	public static synchronized Smoke getUnusedSmoke(Vector3f location) {
		if(unusedSmoke.size() == 0) {
			return new Smoke(location);
		}
		Smoke s = unusedSmoke.pop();
		s.reset(location);
		return s;
	}

	public String getIcon() {
		return "smokeGranade.png";
	}
	

	// We dont need this
	public boolean reload() {
		return false;
	}
}
